package cc.javaee.bbs.dao.awardInfo;

import cc.javaee.bbs.dao.BaseDao;
import cc.javaee.bbs.model.ActiveAward;
import cc.javaee.bbs.model.AwardInfo;
import cc.javaee.bbs.model.PageBean;
import org.springframework.stereotype.Repository;

import java.util.List;
/**
 * 奖品Dao
 * @author admin
 *
 */
@Repository
public class AwardInfoDao extends BaseDao {
	String ns="jbbs_awardInfo.";
	public List<AwardInfo> findpage(PageBean<AwardInfo> page) {
		return this.getSqlSession().selectList(ns+"findpage", page);
	}
	public int findpagecount(PageBean<AwardInfo> page) {
		return this.getSqlSession().selectOne(ns+"findpagecount", page);
	}
	public List<AwardInfo> findbyid(AwardInfo awardInfo) {
		return this.getSqlSession().selectList(ns+"findbyid", awardInfo);
	}
	
	public void insert(AwardInfo awardInfo) {
		this.getSqlSession().insert(ns+"insert", awardInfo);
	}
	public void update(AwardInfo awardInfo) {
		this.getSqlSession().update(ns+"update", awardInfo);
	}

	public void delete(Integer id) {
		this.getSqlSession().delete(ns+"delete", id);
	}
	/**
	 * 查询奖品关联的活动
	 * @param id
	 */
	public List<ActiveAward> findActiveAwards(Integer id) {
		List<ActiveAward>list=this.getSqlSession().selectList(ns+"findActiveAwards", id);
		return list;
	}
	/**
	 * 根据活动ID查询奖品
	 * @param activeId 活动ID
	 * @return
	 */
	public List<AwardInfo>findOrderInfoByActiveId(String activeId){
		List<AwardInfo>list=getSqlSession().selectList(ns+"findOrderInfoByActiveId",Integer.valueOf(activeId));
		return list;
	}

}
